import { createPopupSlot } from '@/services/popupSlot'
import { IOrigRouteListReq } from './interface'

export const popupSlot = createPopupSlot()

export const normalizeReqData = <T extends IOrigRouteListReq | null>(reqData: T): T => {
  if (reqData) {
    if (reqData.waybillNos) {
      const newWaybillNos = reqData.waybillNos.trim().replace(/\s*\n+\s*/, '\n')
      if (reqData.waybillNos !== newWaybillNos) {
        reqData = { ...reqData, waybillNos: newWaybillNos }
      }
    }
  }
  return reqData
}
